Adopt swift-format for linting and formatting#163
Merged
Conversation
No behavior change. - Wrap the 160+ character lines (the worst was 301 characters) in TabView, SwipeMenuView, and SwipeMenuViewController. - Rename single-letter locals (i -> index, m -> maskedCorners). - Drop redundant '= nil' optional initializations in the options. - Remove the stale 2017 'case infinity' TODO; nothing tracks it. - Trailing whitespace/newline fixes.
Add a .swift-format configuration (4-space indent, 160-column lines, existing line breaks respected) and normalize the codebase with the Swift 6 toolchain's built-in formatter: bracket indentation, trailing commas in multiline collections, one variable per declaration, ordered imports, and blank-line normalization. The four .forEach side-effect loops flagged by the ReplaceForEachWithForLoop rule are rewritten as for-in loops. A new swift-format CI job runs 'swift format lint --strict' and then verifies the tree is formatter-clean via git diff --exit-code. It selects the same Xcode as the build jobs so the bundled swift-format matches what contributors run locally. Existing job names are unchanged, so the required status checks are unaffected.
There was a problem hiding this comment.
Reviewed the full diff. This is a mechanical formatting-only change: adds a .swift-format config, applies swift format --in-place across Sources/Tests/Example, converts the four flagged .forEach side-effect loops to for-in, and adds a CI job that lints and verifies formatter-cleanliness.
Spot-checked the non-trivial rewrites for behavior preservation:
- The wrapped multi-line string literal in
SwipeMenuViewController.swift'sassertionFailureuses a trailing\to suppress the line break, so the message text is unchanged. - The
padding/heightlocal-variable hoists inTabView.swift(indicator positioning, circle indicator frame) compute the same values as before, just de-duplicated. - Trailing commas added to multi-line arrays/
NSLayoutConstraint.activate([...])calls and import reordering are semantically inert in Swift. - The new
formatCI job is independent (noneeds:wiring), so it doesn't affect the existing required checks.
No bugs, logic changes, or security issues found. Approving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds lint/format enforcement using the Swift toolchain's first-party
swift format(swiftlang/swift-format, bundled since Swift 6) — no third-party lint dependency..swift-format: 4-space indentation, 160-column line length,respectsExistingLineBreaksso adoption churn stays minimal; everything else is the official default rule set.Sources,Tests, the example app, andPackage.swiftwithswift format --in-place: bracket indentation (the codebase had misaligned])closers), trailing commas in multiline collections, one variable per declaration, ordered imports (@testablelast), and blank-line normalization. Purely mechanical..forEach { … }side-effect loops flagged byReplaceForEachWithForLoopare nowfor-inloops.i→index,m→maskedCorners), dropped redundant= nilinitializations, removed a stale 2017TODO.swift-format(macos-26, samesetup-xcodeselection as the build jobs so CI's swift-format version matches contributors' local toolchain):swift format lint --strict --recursive --parallel …swift format --in-place …+git diff --exit-code— fails if the tree is not formatter-clean and surfaces the diff in the log.Existing job names are unchanged, so the required status checks on
mainare unaffected.Verification
swift format lint --strictpasses with zero findings (swift-format 6.3.0), and the formatter is idempotent on the tree.